﻿using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;

namespace CodedUITestExtensions
{
    /// <summary>
    /// Extensions for mouse.
    /// </summary>
    public static class MouseExtension
    {
        /// <summary>
        /// Executes left mouse button Click() (used for blocked controls).
        /// </summary>
        /// <param name="mouse">Mouse.</param>
        /// <param name="controlBoundingRect">Control BoundingRect.</param>
        public static void ClickOnBlockingControl(this Mouse mouse, Rectangle controlBoundingRect)
        {
            Point clickablePoint = Point.Add(controlBoundingRect.Location,
                new Size(controlBoundingRect.Width / 2, controlBoundingRect.Height / 2));
            Mouse.Click(clickablePoint);
        }
    }
}
